package com.usian.wemedia.controller;

import com.usian.apis.wemedia.WmUserControllerApi;
import com.usian.model.common.dtos.ResponseResult;
import com.usian.model.media.pojos.WmUser;
import com.usian.wemedia.service.WmUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/v1/user")
@Api(value = "用户",tags = "wmuser",description = "用户管理api")
public class WmUserController implements WmUserControllerApi {

    @Autowired
    private WmUserService wmUserService;


    @PostMapping("/save")
    @ApiOperation(value = "用户添加",notes = "用户信息添加")
    @ApiImplicitParam(name = "user",type = "WmUser",value = "用户信息")
    @Override
    public ResponseResult save(@RequestBody WmUser user) {
        return wmUserService.add(user);
    }

    @GetMapping("/findByName")
    @ApiOperation(value = "用户列表查询", notes = "根据用户名进行列表查询" )
    @ApiImplicitParam(name = "name",type = "String",value = "用户名")
    @Override
    public WmUser findByName(String name) {
        return wmUserService.findByUserName(name);
    }

    @GetMapping("/findOne/{id}")
    @Override
    public WmUser findWmUserById(@PathVariable("id") Long id) {
        return wmUserService.getById(id);
    }
}
